package cn.com.surker.base.controller;

import cn.com.surker.base.strength.service.BaseStrengthLevelDosageService;
import cn.com.surker.base.strength.service.StrengthBaseService;
import cn.com.surker.base.strength.vo.StrengthLevelDosageVo;
import cn.com.surker.dto.main.BaseStrengthQueryDTO;
import cn.com.surker.lab.vo.LabLevelConstructVo;
import cn.com.surker.spring.RestResultDto;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/control/strength")
public class BaseStrengthController {

    @Autowired
    private StrengthBaseService strengthBaseService;
    @Resource
    private BaseStrengthLevelDosageService dosageService;

    @PostMapping(value = "/page")
    @ApiOperation(value = "分页方法", tags = "强度等级")
    public RestResultDto pageData(@RequestBody BaseStrengthQueryDTO dto){
        return RestResultDto.success(strengthBaseService.pageData(dto));
    }

    /**
     * 基础标号容重区间
     * @return
     */
    @PostMapping(value = "/find-dosage")
    public RestResultDto findStrength(Long orgId) {
        try {
            List<StrengthLevelDosageVo> list = dosageService.findDosageVo(orgId, null);
            if (list == null)
                return RestResultDto.fail("未获取到容重区间数据");
            return RestResultDto.success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return RestResultDto.fail(e.getMessage());
        }
    }

}
